package Routeviews::DBI;
use base 'Class::DBI';

use 5.008008;
use strict;
use warnings;

our $VERSION = '0.00_01';
$VERSION = eval $VERSION;  # see L<perlmodstyle>

__PACKAGE__->connection('DBI:Pg:database=routeviews;host=localhost','postgres','');
__PACKAGE__->set_sql(_create_me => 'CREATE TABLE __TABLE__ (%s)');
__PACKAGE__->set_sql(_table_pragma => 'select * from pg_stat_user_tables where relname = \'__TABLE__\'');

# Preloaded methods go here.

sub set_table {
    my ($class,$table) = @_;
    $class->table($table);
    $class->_create_table();
}

sub _create_table {
    my $class = shift;
    my @vals = $class->sql__table_pragma->select_row();
    $class->sql__create_me($class->create_sql())->execute() unless(@vals);
}

1;
__END__
# Below is stub documentation for your module. You'd better edit it!

=head1 NAME

Routeviews::DBI - Perl extension for archiving Routeviews data 

=head1 SYNOPSIS

    See Routeviews::Archive, this module meant to be a base-class

=head1 DESCRIPTION

=head1 SEE ALSO

http://code.google.com/p/perl-routeviews/

=head1 AUTHOR

Wes Young, E<lt>saxjazman@cpan.orgE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2010 by Wes Young (claimid.com/wesyoung)
Copyright (C) 2010 by the Trustee's of Indiana University (www.indiana.edu)
Copyright (C) 2010 by the REN-ISAC (www.ren-isac.net)

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.10.0 or,
at your option, any later version of Perl 5 you may have available.


=cut
